Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fractional hex on HexLayout #141

Merged
merged 3 commits into from
Jan 24, 2024
Merged

Fractional hex on HexLayout #141

merged 3 commits into from
Jan 24, 2024

Conversation

ManevilleF
Copy link
Owner

@ManevilleF ManevilleF commented Jan 24, 2024

Closes #138
Supercedes #140

Re implementation of #140 by @msparkles

I added CHANGELOG entries and some code clarifications.

Work done

Added the capacity to use fractional axial coordinates as Vec2 in HexLayout methods:

  • Added HexLayout::fract_hex_to_world_pos method
  • Added HexLayout::world_pos_to_fract_hex method

To avoid duplication and multi-method chaining I encapsulated the matrix computations in:

  • Added HexOrientationData::forward method
  • Added HexOrientationData::inverse method

I also added these utility methods:

  • Added Hex::to_array_f32 utility method
  • Added Hex::to_cubic_array_f32 utility method

@ManevilleF ManevilleF marked this pull request as ready for review January 24, 2024 09:11
@msparkles
Copy link

@ManevilleF Semirelated, why not just use Vec2? You can actually deconstruct them like this:
fn foo(Vec2 { x, y }: Vec2)

...It's weird, no idea why Rust made it this way, but

@ManevilleF
Copy link
Owner Author

@ManevilleF Semirelated, why not just use Vec2? You can actually deconstruct them like this: fn foo(Vec2 { x, y }: Vec2)

...It's weird, no idea why Rust made it this way, but

Where ? The HexLayout methods do use a Vec2

@msparkles
Copy link

This

fn matrix_op(matrix: [f32; 4], [x, y]: [f32; 2]) -> [f32; 2] {

(on phone, dunno how to make links to lines on phone, soz)

@ManevilleF
Copy link
Owner Author

Yeah that is voluntary, I try to keep internal code as dependency free as possible, in the future I wish to have glam as an optional dependency

@ManevilleF ManevilleF merged commit 6a4bbd3 into main Jan 24, 2024
9 checks passed
@ManevilleF ManevilleF deleted the feat/partial_fractional_hex branch January 24, 2024 21:03
@ManevilleF ManevilleF added this to the 0.13.0 milestone Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fractional version of Hex and a variant in HexLayout for converting pixel to unrounded Hex
2 participants